package apps.generate.service;

import java.util.ArrayList;
import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.web.bind.annotation.ResponseBody;

import apps.generate.dao.DBFieldDAO;
import apps.generate.domain.DBFieldBean;
import core.tool.common.SystemInfo;
import core.tool.template.freemarker.FreemarkerUtil;
import core.web.easyui.GridColumn;

@Service("dBFieldService")
public class DBFieldService {
	
    @Autowired
	private DBFieldDAO dbFieldDAO;
	
	public List<GridColumn> getGridColumns(String tableName) {
		List<GridColumn> result=new ArrayList<GridColumn>();
		List<DBFieldBean> list=dbFieldDAO.getFieldListOfTableName(tableName);
		for(DBFieldBean dbBean:list) {
			GridColumn gridColumn=new GridColumn(dbBean.getRemark(),dbBean.getFieldName().toLowerCase().replace("_", ""));
			result.add(gridColumn);
		}
		return result;
	}

	public List<DBFieldBean> getDBFieldBeans(String tableName) {
		List<DBFieldBean> list=dbFieldDAO.getFieldListOfTableName(tableName);
		return list;
	}
	
	public DBFieldDAO getDbFieldDAO() {
		return dbFieldDAO;
	}

	public void setDbFieldDAO(DBFieldDAO dbFieldDAO) {
		this.dbFieldDAO = dbFieldDAO;
	}
	
	

}
